package org.fuys.etp.core.metrics;

import org.fuys.etp.core.model.vo.TpStatusVO;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @projectName: fuys-etp
 * @package: org.fuys.etp.core.metrics
 * @className: EtpMetricsHandlerChain
 * @author: WangJing
 * @description: 指标收集链路
 * @date: 2025/2/5 13:14
 * @version: 1.0
 */
public class EtpMetricsHandlerChain {
    private List<EtpMetricsHandler> etpMetricsHandlers = new ArrayList<>();

    public TpStatusVO collectStatus(ThreadPoolExecutor executor){
        if(etpMetricsHandlers == null){
            return null;
        }
        TpStatusVO tpStatusVO = new TpStatusVO();
        for (EtpMetricsHandler etpMetricsHandler : etpMetricsHandlers) {
            etpMetricsHandler.metricsCollect(executor,tpStatusVO);
        }
        return tpStatusVO;
    }

    public void addMetricsHandler(EtpMetricsHandler etpMetricsHandler){
        etpMetricsHandlers.add(etpMetricsHandler);
    }
}
